package day08

import kafka.producer.Partitioner
import kafka.utils.{Utils, VerifiableProperties}

//注意：自定义分区器坑： 自定义类必须要有一个构造参数：(props: VerifiableProperties = null) 。不然会出问题
class MyPartitioner(props: VerifiableProperties = null) extends Partitioner{
  override def partition(key: Any, numPartitions: Int): Int = {
    Utils.abs(key.hashCode) % numPartitions
  }
}

